<!--#include file="../../../core/common/Conn.asp" -->
<!--#include file="../../../core/common/Limit.asp" -->
<!--#include file="../../../core/common/Function.asp" -->
<%
	dim action
	action = request.QueryString("action")
	if action = "edit" then
		call edit
	end if
	call default
	
	dim ID,TITLE,LINK,CONTENT,UPDATETIME,IMAGE,AUTHOR,SUBJECTID
	
	'加载内容
	sub default
		SUBJECTID = request.QueryString("subjectid")
		ID = request.QueryString("id")
		
		dim rs,sql
		sql = "select * from [NEWS] where ID = "& ID
		set rs = db.query(sql)
		if not rs.eof then
			TITLE = rs("TITLE")
			LINK = rs("LINK")
			CONTENT = rs("CONTENT")
			UPDATETIME = rs("UPDATETIME")
			IMAGE = rs("IMAGE")
			AUTHOR = rs("AUTHOR")
		else
			TITLE = ""
			LINK = ""
			CONTENT = ""
			UPDATETIME = ""
			IMAGE = ""
			AUTHOR = ""
		end if
		rs.close
		set rs = nothing
	end sub
	
	'编辑内容
	sub edit
		SUBJECTID = request.Form("SUBJECTID")
		ID = request.Form("ID")
		TITLE = request.Form("TITLE")
		LINK = request.Form("LINK")
		CONTENT = request.Form("CONTENT")
		UPDATETIME = now
		IMAGE = request.Form("IMAGE")
		AUTHOR = request.Cookies("USERINFO")("USERNAME")
		
		dim rs,sql
		sql = "select * from [NEWS] where ID = " & ID
		set rs = db.query(sql)
		if not rs.eof then
			rs("TITLE") = TITLE
			rs("LINK") = LINK
			rs("CONTENT") = CONTENT
			rs("UPDATETIME") = UPDATETIME
			rs("IMAGE") = IMAGE
			rs("AUTHOR") = AUTHOR
			rs.update
		end if
		rs.close
		set rs = nothing
		
		response.Redirect("index.asp?subjectid=" & SUBJECTID)
	end sub
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CMSLite for ASP</title>
<link href="../../resource/css/reset.css" rel="stylesheet" type="text/css" />
<link href="../../resource/css/main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../../resource/js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="../../resource/js/common.js"></script>

<link href="../../resource/js/kindeditor/themes/default/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../../resource/js/kindeditor/kindeditor.js"></script>
<script type="text/javascript" src="../../resource/js/kindeditor/lang/zh_CN.js"></script>
<script type="text/javascript">
//初始化编辑器
var editor;
KindEditor.ready(function(K) {
	editor = K.create('#editor',{
		uploadJson : '../../resource/js/kindeditor/asp/upload_json.asp',
		fileManagerJson : '../../resource/js/kindeditor/asp/file_manager_json.asp',
		allowFileManager : true,
		clickUploadButton : function(url,type){
			//当上传内容为图片
			if (type == "image")
				$("#IMAGE").val(url);
		}
	});
});
</script>
</head>

<body id="body">
	<div class="title_bar">
	修改 - <%=Get_Subject_Name(SUBJECTID)%>
	</div>
	<form action="?action=edit" method="post">
	<p>
		<label>标题</label>
		<input type="text" name="TITLE" id="TITLE" class="textbox" value="<%=TITLE%>" />
	</p>
	<p>
		<label>外链</label>
		<input type="text" name="LINK" id="LINK" class="textbox" value="<%=LINK%>" />
	</p>
	<p>
		<label>内容</label>
		<textarea name="CONTENT" id="editor" tabindex="1" style="width:100%;height:300px;margin:0 auto;">
		<%=CONTENT%>
		</textarea>
	</p>
	<p>
	上次修改时间：<%=UPDATETIME%><br />
	修改用户：<%=AUTHOR%>
	</p>
	<p>
		<input type="submit" class="button_1" value="修改" />
		<input type="button" class="button_1" value="返回" onclick="location.href='index.asp?subjectid=<%=SUBJECTID%>';" />
		<input type="hidden" name="ID" value="<%=ID%>" />
		<input type="hidden" name="SUBJECTID" value="<%=SUBJECTID%>" />
		<input type="hidden" id="IMAGE" name="IMAGE" value="<%=IMAGE%>" />
	</p>
	</form>
</body>
</html>
